
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第6章 广播常用设置 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../07_扫描/07_扫描.html" />
    
    
    <link rel="prev" href="../05_广播/05_广播.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../01_低功耗蓝牙简介/01_低功耗蓝牙简介.html">
            
                <a href="../01_低功耗蓝牙简介/01_低功耗蓝牙简介.html">
            
                    
                    第1章 低功耗蓝牙简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../02_低功耗蓝牙协议栈分析/02_低功耗蓝牙协议栈分析.html">
            
                <a href="../02_低功耗蓝牙协议栈分析/02_低功耗蓝牙协议栈分析.html">
            
                    
                    第2章 低功耗蓝牙协议栈分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../03_BLE的一些概念/03_BLE的一些概念.html">
            
                <a href="../03_BLE的一些概念/03_BLE的一些概念.html">
            
                    
                    第3章 BLE的一些概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../04_TMOS说明/04_TMOS说明.html">
            
                <a href="../04_TMOS说明/04_TMOS说明.html">
            
                    
                    第4章 TMOS说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../05_广播/05_广播.html">
            
                <a href="../05_广播/05_广播.html">
            
                    
                    第5章 广播
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="06_广播常用设置.html">
            
                <a href="06_广播常用设置.html">
            
                    
                    第6章 广播常用设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../07_扫描/07_扫描.html">
            
                <a href="../07_扫描/07_扫描.html">
            
                    
                    第7章 扫描
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第6章 广播常用设置</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5E7F;&#x64AD;&#x5E38;&#x7528;&#x8BBE;&#x7F6E;">&#x5E7F;&#x64AD;&#x5E38;&#x7528;&#x8BBE;&#x7F6E;</h1>
<h2 id="1&#x3001;-&#x8BBE;&#x7F6E;&#x5E7F;&#x64AD;&#x901A;&#x9053;-37&#x3001;38&#x3001;39">1&#x3001; &#x8BBE;&#x7F6E;&#x5E7F;&#x64AD;&#x901A;&#x9053; 37&#x3001;38&#x3001;39</h2>
<p>&#x9ED8;&#x8BA4;&#x4E09;&#x4E2A;&#x5E7F;&#x64AD;&#x901A;&#x9053;&#x5168;&#x90E8;&#x6253;&#x5F00;</p>
<pre><code class="lang-C"><span class="hljs-comment">// GAP_ADVCHAN_DEFINES GAP Advertisement Channel Map</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> GAP_ADVCHAN_37  0x01  <span class="hljs-comment">//!&lt; Advertisement Channel 37</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> GAP_ADVCHAN_38  0x02  <span class="hljs-comment">//!&lt; Advertisement Channel 38</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> GAP_ADVCHAN_39  0x04  <span class="hljs-comment">//!&lt; Advertisement Channel 39</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> GAP_ADVCHAN_ALL (GAP_ADVCHAN_37 | GAP_ADVCHAN_38 | GAP_ADVCHAN_39) <span class="hljs-comment">//!&lt; All Advertisement Channels Enabled</span></span>

<span class="hljs-comment">//&#x6DFB;&#x52A0;&#x81F3;Broadcaster_Init() &#x5E7F;&#x64AD;&#x521D;&#x59CB;&#x5316;&#x51FD;&#x6570;&#x4E2D;</span>
<span class="hljs-keyword">uint8_t</span> init_adv_channel_map = GAP_ADVCHAN_37;
GAPRole_SetParameter( GAPROLE_ADV_CHANNEL_MAP, <span class="hljs-keyword">sizeof</span>( <span class="hljs-keyword">uint8_t</span> ), &amp;init_adv_channel_map );
</code></pre>
<h2 id="2&#x3001;&#x8BBE;&#x7F6E;&#x5E7F;&#x64AD;&#x95F4;&#x9694;">2&#x3001;&#x8BBE;&#x7F6E;&#x5E7F;&#x64AD;&#x95F4;&#x9694;</h2>
<pre><code class="lang-C"><span class="hljs-comment">// What is the advertising interval when device is discoverable (units of 625us, 160=100ms)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DEFAULT_ADVERTISING_INTERVAL          160</span>
</code></pre>
<p>EVT&#x4E2D;&#x7684;&#x5E7F;&#x64AD;&#x6A21;&#x5F0F;&#x7684;&#x4F8B;&#x7A0B;&#xFF0C;&#x90FD;&#x662F;&#x4E0D;&#x53EF;&#x8FDE;&#x63A5;&#x7684;&#x5E7F;&#x64AD;&#x5305;&#xFF0C;&#x6700;&#x4F4E;&#x5E7F;&#x64AD;&#x95F4;&#x9694;&#x4E3A;100ms</p>
<h2 id="3&#x3001;&#x5F00;&#x542F;&#x5173;&#x95ED;&#x5E7F;&#x64AD;">3&#x3001;&#x5F00;&#x542F;/&#x5173;&#x95ED;&#x5E7F;&#x64AD;</h2>
<pre><code class="lang-C"><span class="hljs-comment">//&#x6DFB;&#x52A0;&#x81F3;Broadcaster_Init() &#x5E7F;&#x64AD;&#x521D;&#x59CB;&#x5316;&#x51FD;&#x6570;&#x4E2D;</span>

<span class="hljs-comment">/* &#x5F00;&#x542F;&#x5E7F;&#x64AD; */</span>
<span class="hljs-keyword">uint8_t</span> initial_advertising_enable = TRUE;
<span class="hljs-comment">// Set the GAP Role Parameters</span>
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, <span class="hljs-keyword">sizeof</span>( <span class="hljs-keyword">uint8_t</span> ), &amp;initial_advertising_enable );

<span class="hljs-comment">/* &#x5173;&#x95ED;&#x5E7F;&#x64AD; */</span>
<span class="hljs-keyword">uint8_t</span> initial_advertising_enable = FALSE;
<span class="hljs-comment">// Set the GAP Role Parameters</span>
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, <span class="hljs-keyword">sizeof</span>( <span class="hljs-keyword">uint8_t</span> ), &amp;initial_advertising_enable );
</code></pre>
<h2 id="4&#x3001;&#x8BBE;&#x7F6E;&#x6709;&#x9650;&#x53EF;&#x53D1;&#x73B0;&#x6A21;&#x5F0F;--&#xFF08;gapadtypeflagslimited&#xFF09;">4&#x3001;&#x8BBE;&#x7F6E;&#x6709;&#x9650;&#x53EF;&#x53D1;&#x73B0;&#x6A21;&#x5F0F;  &#xFF08;GAP_ADTYPE_FLAGS_LIMITED&#xFF09;</h2>
<pre><code class="lang-C"><span class="hljs-comment">//&#x8BBE;&#x7F6E;GAP_ADTYPE_FLAGS &#x4E3A;&#x6709;&#x9650;&#x53EF;&#x53D1;&#x73B0;&#x6A21;&#x5F0F;</span>
<span class="hljs-number">0x02</span>,   <span class="hljs-comment">// length of this data</span>
GAP_ADTYPE_FLAGS,
GAP_ADTYPE_FLAGS_LIMITED | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,   <span class="hljs-comment">//&#x9ED8;&#x8BA4;180s&#x540E;&#x5173;&#x95ED;&#x5E7F;&#x64AD;</span>

<span class="hljs-comment">/* &#x4FEE;&#x6539;&#x5E7F;&#x64AD;&#x65F6;&#x957F;&#xFF08;&#x5E7F;&#x64AD;x&#x79D2;&#x540E;&#x505C;&#x6B62;&#xFF09; */</span>
<span class="hljs-keyword">uint16_t</span> adv_timeout  = <span class="hljs-number">5</span>; <span class="hljs-comment">//&#x5355;&#x4F4D;&#x4E3A;&#x79D2;  </span>
GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, adv_timeout );
</code></pre>
<ul>
<li>&#x5982;&#x9700;&#x9650;&#x5236;&#x5E7F;&#x64AD;&#x5728; 5s &#x4E4B;&#x540E;&#x505C;&#x6B62;&#xFF0C;&#x7136;&#x540E; 60s &#x4E4B;&#x540E;&#x81EA;&#x52A8;&#x91CD;&#x65B0;&#x5E7F;&#x64AD;&#xFF0C;&#x5982;&#x6B64;&#x53CD;&#x590D;&#xFF0C;&#x53EF;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5B9A;&#x65F6;&#x4E8B;&#x4EF6;&#xFF0C;&#x6BCF; (60+5)s &#x5F00;&#x542F;&#x4E00;&#x6B21;&#x5E7F;&#x64AD;&#x3002;</li>
</ul>
<h2 id="5&#x3001;&#x666E;&#x901A;&#x53D1;&#x73B0;&#x6A21;&#x5F0F;-&#xFF08;gapadtypeflagsgeneral&#xFF09;">5&#x3001;&#x666E;&#x901A;&#x53D1;&#x73B0;&#x6A21;&#x5F0F; &#xFF08;GAP_ADTYPE_FLAGS_GENERAL&#xFF09;</h2>
<pre><code class="lang-C"><span class="hljs-comment">//&#x8BBE;&#x7F6E;GAP_ADTYPE_FLAGS &#x4E3A;&#x666E;&#x901A;&#x53EF;&#x53D1;&#x73B0;&#x6A21;&#x5F0F;</span>
<span class="hljs-number">0x02</span>,   <span class="hljs-comment">// length of this data</span>
GAP_ADTYPE_FLAGS,
GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,  <span class="hljs-comment">//&#x9ED8;&#x8BA4;&#x4E00;&#x76F4;&#x5E7F;&#x64AD;</span>

<span class="hljs-comment">/* &#x4FEE;&#x6539;&#x5E7F;&#x64AD;&#x65F6;&#x957F;&#xFF08;&#x5E7F;&#x64AD;x&#x79D2;&#x540E;&#x505C;&#x6B62;&#xFF09; */</span>
<span class="hljs-keyword">uint16_t</span> adv_timeout  = <span class="hljs-number">8000</span>; <span class="hljs-comment">//&#x5355;&#x4F4D;&#x4E3A;0.625ms   5s</span>
GAP_SetParamValue( TGAP_GEN_DISC_ADV_MIN, adv_timeout );
</code></pre>
<h2 id="6&#x3001;&#x52A8;&#x6001;&#x66F4;&#x65B0;&#x5E7F;&#x64AD;&#x6570;&#x636E;">6&#x3001;&#x52A8;&#x6001;&#x66F4;&#x65B0;&#x5E7F;&#x64AD;&#x6570;&#x636E;</h2>
<pre><code class="lang-C"><span class="hljs-function"><span class="hljs-keyword">extern</span> bStatus_t <span class="hljs-title">GAP_UpdateAdvertisingData</span><span class="hljs-params">( uint8_t taskID,uint8_t adType,uint8_t dataLen,uint8_t *pAdvertData )</span></span>;
</code></pre>
<ul>
<li>taskID&#xFF1A; &#x8BF7;&#x6C42;&#x66F4;&#x6539;&#x5E7F;&#x64AD;&#x4EFB;&#x52A1;&#x7684;ID</li>
<li>adType&#xFF1A;<strong>TRUE</strong>&#x66F4;&#x6539;&#x5E7F;&#x64AD;&#x6570;&#x636E;&#xFF0C;<strong>FALSE</strong>&#x66F4;&#x6539;&#x626B;&#x63CF;&#x56DE;&#x590D;&#x6570;&#x636E;</li>
<li>datalen&#xFF1A;&#x6570;&#x636E;&#x957F;&#x5EA6;</li>
<li>*pAdvertData&#xFF1A;&#x6570;&#x636E;&#x6307;&#x9488;</li>
</ul>
<h2 id="7&#x3001;&#x4FEE;&#x6539;&#x5E7F;&#x64AD;mac&#x5730;&#x5740;">7&#x3001;&#x4FEE;&#x6539;&#x5E7F;&#x64AD;MAC&#x5730;&#x5740;</h2>
<p>Pproperties -&gt; C/C++ General -&gt; Paths and Symbols -&gt; Symbols -&gt; GNU C</p>
<p>&#x6DFB;&#x52A0;&#x5B8F;&#x5B9A;&#x4E49;</p>
<pre><code class="lang-C">BLE_MAC == TRUE
</code></pre>
<p><img src="image/modify_BLE_MAC.png" alt="modify_BLE_MAC"></p>
<p>&#x901A;&#x5E38;&#x5728;xx_main.c&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5B9A;&#x4E49;&#x4E86;<strong>MacAddr[6]</strong>&#x6570;&#x7EC4;&#xFF0C;&#x7528;&#x4E8E;&#x81EA;&#x5B9A;&#x4E49;MAC&#x5730;&#x5740;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">if</span> (defined (BLE_MAC)) &amp;&amp; (BLE_MAC == TRUE)</span>
u8C MacAddr[<span class="hljs-number">6</span>] =
{ <span class="hljs-number">0x84</span>,<span class="hljs-number">0xC2</span>,<span class="hljs-number">0xE4</span>,<span class="hljs-number">0x03</span>,<span class="hljs-number">0x02</span>,<span class="hljs-number">0x02</span>};
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
</code></pre>
<footer class="page-footer"><span class="copyright">powered by Gitbook</span><span class="footer-modification">File Modify: 
2021-11-16 10:53:14
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../05_广播/05_广播.html" class="navigation navigation-prev " aria-label="Previous page: 第5章 广播">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../07_扫描/07_扫描.html" class="navigation navigation-next " aria-label="Next page: 第7章 扫描">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第6章 广播常用设置","level":"1.7","depth":1,"next":{"title":"第7章 扫描","level":"1.8","depth":1,"path":"07_扫描/07_扫描.md","ref":"07_扫描/07_扫描.md","articles":[]},"previous":{"title":"第5章 广播","level":"1.6","depth":1,"path":"05_广播/05_广播.md","ref":"05_广播/05_广播.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["-lunr","-search","-sharing","search-pro","back-to-top-button","chapter-fold","splitter","tbfed-pagefooter","popup","intopic-toc","copy-code-button","github","hide-element","pageview-count","livereload"],"pluginsConfig":{"tbfed-pagefooter":{},"chapter-fold":{},"github":{"url":"https://gitee.com/taoyukai/ch32v307_development_guide"},"intopic-toc":{"isCollapsed":true,"isScrollspyActive":true,"label":"In this article","maxDepth":6,"mode":"nested","selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section h5, .markdown-section h6","visible":true},"livereload":{},"splitter":{},"search-pro":{},"popup":{},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"pageview-count":{},"copy-code-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"06_广播常用设置/06_广播常用设置.md","mtime":"2021-11-16T02:53:14.092Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T03:05:52.403Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

